package com.eric.learning.a.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.eric.learning.a.block.BlockHandler;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenw-i
 * @version 1.0.0
 * @ClassName DemoController.java
 * @Description TODO
 * @createTime 2020年07月13日 16:35:00
 */
@RestController
public class DemoController {

    @Value("${spring.application.name:service-a}")
    String applicationName;

    @GetMapping("/get")
    public String get(){
        return "get success";
    }

    @GetMapping("/resource")
    @SentinelResource(value = "byResource",blockHandler = "handleBlock",blockHandlerClass = BlockHandler.class)
    public String resource(){
        return applicationName+ "=>  resource success";
    }


}
